home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
L' Effet Pommier 2
/
L'Effet Pommier - Volume 02.iso
/
Réflexion
/
Giaco
/
CodeComputer.p
next >
Wrap
Text File
|
1993-04-09
|
2KB
|
47 lines
unit ComputerRsrc;
{compile it as a code resource of type 'GGGG' with ID=128, but the Project is already setted to do it}
{and then copy and PASTE it with ResEdit into Giaco resource fork.}
interface
type
sqboolarray = array[1..70] of boolean;
InfoRec = record
squares: sqboolarray; {this array tells you which squares are already occupied (=true), 70 is the max number of squares for the game}
Numberofsquares: integer; {number of squares of the current match}
Yourmove: integer; {This is the number you have to modify, and tells that}
{your move will occupy the yourmove and yourmove+1 squares}
end; {for istance, if you set Myinfoptr.Yourmove:=2, this means that you occupy}
{squares 2 and 3 with your piece. Check squares[2] and squares[3]}
{to be sure they are empy (false)}
InfoPtr = ^InfoRec;
procedure Main (Myinfoptr: InfoPtr);
implementation
procedure Main (Myinfoptr: InfoPtr);
var
i: integer; { <- needs only to show a stupid computer algo}
{put here all the variables you need, remembering that each time you receive the}
{board situation (Myinfoptr. squares)}
begin
{Here you have to tell which is your move setting the Myinfoptr.yourmove field}
{remember to check the move is possible if you don't want to lose the game}
{the following is an example of a 'stupid computer'}
i := 1;
Myinfoptr^.Yourmove := 0;
repeat
while Myinfoptr^.squares[i] do {goes to the first free square, and it has to be one move, otherwise the game}
i := i + 1; {already ended.}
if not Myinfoptr^.squares[i + 1] then {if even the next one is free than make that move}
Myinfoptr^.Yourmove := i;
i := i + 1;
until (Myinfoptr^.Yourmove <> 0) or (i >= Myinfoptr^.numberofsquares);
end;
end. {for any question or explanation or whatever you want to speak about e-mail to}
{turner@sabrina.dei.unipd.it}